﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data;

namespace CAD.DAO
{
    public class DAOCentrodeCostos_Asignacion_Personal
    {
        public int Insertar(int LPERSONAL_ID, int LCENTRODECOSTOS_ID, int IPORCENTAJE, DateTime DFECHA_DT, int ICONCURRENCIA)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();
            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LPERSONAL_ID ";
            prmA.Value = LPERSONAL_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);

            DbParameter prmAa = new SqlParameter();
            prmAa.DbType = DbType.Int32;
            prmAa.ParameterName = "@LCENTRODECOSTOS_ID ";
            prmAa.Value = LCENTRODECOSTOS_ID;
            prmAa.Direction = ParameterDirection.Input;
            lstParametros.Add(prmAa);

            DbParameter prmCa = new SqlParameter();
            prmCa.DbType = DbType.Int32;
            prmCa.ParameterName = "@IPORCENTAJE ";
            prmCa.Value = IPORCENTAJE;
            prmCa.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCa);

            DbParameter prmCas = new SqlParameter();
            prmCas.DbType = DbType.DateTime;
            prmCas.ParameterName = "@DFECHA_DT ";
            prmCas.Value = DFECHA_DT;
            prmCas.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCas);

            DbParameter prmC = new SqlParameter();
            prmC.DbType = DbType.Int32;
            prmC.ParameterName = "@ICONCURRENCIA ";
            prmC.Value = 1;
            prmC.Direction = ParameterDirection.Input;
            lstParametros.Add(prmC);

            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 1;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);

            SQLConexion conProxy = new SQLConexion();
            if (conProxy.EjecutarDML(lstParametros, "dbo.SPABM_TBL_CENTRODECOSTOS_ASIGNACION_TBL_PERSONAL"))
                return Convert.ToInt32(prmA.Value);
            return -1;

        }

        public bool Actualizar(int LPERSONAL_ID, int LCENTRODECOSTOS_ID, int IPORCENTAJE, DateTime DFECHA_DT, int ICONCURRENCIA)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LPERSONAL_ID";
            prmA.Value = LPERSONAL_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);

            DbParameter prmAa = new SqlParameter();
            prmAa.DbType = DbType.Int32;
            prmAa.ParameterName = "@LCENTRODECOSTOS_ID";
            prmAa.Value = LCENTRODECOSTOS_ID;
            prmAa.Direction = ParameterDirection.Input;
            lstParametros.Add(prmAa);

            DbParameter prmCa = new SqlParameter();
            prmCa.DbType = DbType.Int32;
            prmCa.ParameterName = "@IPORCENTAJE ";
            prmCa.Value = IPORCENTAJE;
            prmCa.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCa);

            DbParameter prmCas = new SqlParameter();
            prmCas.DbType = DbType.DateTime;
            prmCas.ParameterName = "@DFECHA_DT ";
            prmCas.Value = DFECHA_DT;
            prmCas.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCas);

            DbParameter prmC = new SqlParameter();
            prmC.DbType = DbType.Int32;
            prmC.ParameterName = "@ICONCURRENCIA ";
            prmC.Value = 1;
            prmC.Direction = ParameterDirection.Input;
            lstParametros.Add(prmC);

            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 2;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarDML(lstParametros, "dbo.SPABM_TBL_CENTRODECOSTOS_ASIGNACION_TBL_PERSONAL");
        }
        public bool Eliminar(int LCENTRODECOSTOS_ASIGNACION_TBL_PERSONAL)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LCENTRODECOSTOS_ASIGNACION_TBL_PERSONAL";
            prmA.Value = LCENTRODECOSTOS_ASIGNACION_TBL_PERSONAL;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);
            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 3;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);

            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarDML(lstParametros, "dbo.SPABM_TBL_CENTRODECOSTOS_ASIGNACION_TBL_PERSONAL");
        }
        public DataSet Traer()
        {
            List<DbParameter> lstParametros = new List<DbParameter>();
            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 4;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarConsulta(lstParametros, "dbo.SPABM_TBL_CENTRODECOSTOS_ASIGNACION_TBL_PERSONAL");
        }
        public DataSet TraerXId(int LPERSONAL_ID, int LCENTRODECOSTOS_ID)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LPERSONAL_ID";
            prmA.Value = LPERSONAL_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);
            DbParameter prmAA = new SqlParameter();
            prmAA.DbType = DbType.Int32;
            prmAA.ParameterName = "@LCENTRODECOSTOS_ID";
            prmAA.Value = LCENTRODECOSTOS_ID;
            prmAA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmAA);
            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 5;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarConsulta(lstParametros, "dbo.SPABM_TBL_CENTRODECOSTOS_ASIGNACION_TBL_PERSONAL");
        }
        public DataSet SumadeProcentaje(int LPERSONAL_ID)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LPERSONAL_ID";
            prmA.Value = LPERSONAL_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);
            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 8;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarConsulta(lstParametros, "dbo.SPABM_TBL_CENTRODECOSTOS_ASIGNACION_TBL_PERSONAL");
    
        }
        public DataSet bUSCARSIEXISTE(int LPERSONAL_ID, int LCENTRODECOSTOS_ID)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LPERSONAL_ID";
            prmA.Value = LPERSONAL_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);
            DbParameter prmAA = new SqlParameter();
            prmAA.DbType = DbType.Int32;
            prmAA.ParameterName = "@LCENTRODECOSTOS_ID";
            prmAA.Value = LCENTRODECOSTOS_ID;
            prmAA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmAA);
            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 7;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarConsulta(lstParametros, "dbo.SPABM_TBL_CENTRODECOSTOS_ASIGNACION_TBL_PERSONAL");
        }

    }
}
